#ifndef GL_SHADER_MANAGER_H
#define GL_SHADER_MANAGER_H

#include "oglHeaders.hh"

#include<vector>
#include<string>

typedef enum InstanceAttribType_s{
   InstAttr_Matrix,
   InstAttr_Vector,
   InstAttr_Float,
   
}InstanceAttribType;

struct GLShaderInfo
{
   GLuint mCompiledID;
   GLenum mShaderType;
   std::string mSourceData;
   GLShaderInfo(GLuint id, GLenum type, std::string data){
      mCompiledID = id;
      mShaderType = type;
      mSourceData = data;
   }
};


//singleton pattern
class GLShaderManager
{
public:
   static GLShaderManager* GetSingleton(void);

   bool CompileShader(const char* shader_name, GLenum shader_type);

   bool CheckShaderCompile(unsigned int shader_id, std::string& error);
   bool CheckShaderLink(unsigned int program_id, std::string& error);
   
   bool LinkToProgram(void);

   void Run(void);
   
   bool FillGLInstanceAttribBegin(unsigned int buf_id);
   // need to set a inter static var to save the current offset 
   bool FillGLInstanceAttrib(const char* attrib_name, InstanceAttribType type, unsigned int attrib_stride);

   void FillGLInstanceAttribEnd(void);

      
private:
   GLShaderManager(void);
   ~GLShaderManager(void);

private:
   static GLShaderManager* _mSingleton;
   std::vector<GLShaderInfo> _mShaderVector;
   GLuint _mProgramID;
   int _mLastAttribPos;
   
};

#endif //GL_SHADER_MANAGER_H
